package com.itheima_01;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test02 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class aClass = Class.forName("com.itheima_01.Student");
        Constructor constructor = aClass.getConstructor();
        Student student = (Student) constructor.newInstance();

        System.out.println("----------------------------------");

        Class aClass1 = Class.forName("com.itheima_01.Student");
        Student student1 = (Student) aClass1.newInstance();


        System.out.println("-----------------------------------------");
        Class aClass2 = Class.forName("com.itheima_01.Student");
        Constructor declaredConstructor = aClass2.getDeclaredConstructor(String.class);
        declaredConstructor.setAccessible(true);
            Student student2 = (Student) declaredConstructor.newInstance("zhangsan");





    }
}
